﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>用户申请结果</title>
		<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8">
		<link rel="stylesheet" href="../css/bootstrap-3.3.7-dist/css/bootstrap.css">
		<link rel="stylesheet" href="../css/body.css"/>
		<link rel="stylesheet" href="../css/dividePage.css">
		<script src="../js/jQuery.js"></script>
		<script src="../css/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
		<script src="../js/bootstrap-paginator.js"></script>
		<script src="../js/index.js"></script>
		<script src="../js/dividePage.js"></script>
		<script src="../js/onloadex.js"></script>
	</head>
	<body>
		<!--首页初始导航条-->
		<nav class="navbar navbar-inverse navbar-fixed-top">
			<div class="container">
				<div class="navbar-header">
					<span class="navbar-brand logo1">川农车辆预约系统</span>
					<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#m1">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
				</div>
				<div class="navbar-collapse collapse" id="m1">
					<ul class="nav navbar-nav navbar-left">
						<li class="active">
							<a href="../index/index.html"><span class="glyphicon glyphicon-home"></span>&nbsp;首页</a><!--这里的span是设置bootstrap字体图标类-->
						</li>
						
						<!--一个下拉菜单-->
						<!--<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
								长期车辆申请
								<b class="caret"></b>
							</a>
							<ul class="dropdown-menu">
								<li>
									<a href="../index/fileDownload.html">表单下载</a>
								</li>
								<li>
									<a href="../index/longResults.html">结果公示</a>
								</li>
							</ul>
						</li>-->
					</ul>
					
					<ul class="nav navbar-nav navbar-right" id="loginWho">
						<li><a href="../index/login.html">登陆</a></li>
					</ul>
				</div>
			</div>
		</nav>
		
		<div class="container allStyle">
			<table class="table table-bordered table-striped " id="userInstrument">
				<tr>
					<!-- <th>申请id</th> -->
					<th>申请人</th>
					<th>车牌号</th>
					<th>申请校区</th>
					<th>申请来访时间</th>
					<th>拒绝理由</th>
					<th>申请结果</th>
					<!--<th>操作</th>-->
				</tr>
				<!--这个地方会显示回显的后台中的公告数据>-->
				<tbody id="tbody">
        		</tbody>
			</table>
<!-- 			<ul id="pageLimit"></ul>  -->
		</div>


		<!--分页-->
		<div class="pageDiv"></div>
		<!--用来存放总页数，放置在body中-->
	</body>
	<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.min.js"></script> -->
	<script>
		var data3;
		var tbody1 = "";
		$.ajax({
				async: false,
				type: "GET",
				url: "https://carorder.sicau.edu.cn/userCar/showOrder",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("userId", sessionStorage.userId);
					// xhr.setRequestHeader("userName", sessionStorage.userName);
				},
				data:{
					page:1,
					pageSize:10,
				},
				dataType: "text",
				contentType: "application/json",
				success: function(data) {
					//console.log(data3);
					//data3 = data3.slice(4);console.log(data3); 
					data3 = eval('(' + data + ')');
					if(data3.total%10 == 0){
						sessionStorage.allPage = parseInt(data3.total/10);
					}else{
						sessionStorage.allPage = parseInt(data3.total/10+1);
					}
					if (data3 == 0) {						
						tbody1 = "<tr><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td></tr>";
					}
					else{
						jQuery.each(data3.result, function(i, value) {
						var trs = "<tr><td hidden>" + value.id + "</td> <td>" + value.name + "</td> <td>" + value.plateId + "</td> <td>";
						if (value.campus==0) {
							trs = trs + "温江" + "</td> <td>";
						}
						else if (value.campus==1) {
							trs = trs + "雅安" + "</td> <td>";
						}
						else{
							trs = trs + "都江堰" + "</td> <td>";
						}

						//var date3 = new Date(parseInt(value.beginDate) * 1000);
						//Y3 = date3.getFullYear() + '-';
						//M3 = date3.getMonth() + 1 + '-';
						//D3 = date3.getDate() + ' ';
						//date3 = Y3 + M3 + D3;

						//var date4 = new Date(parseInt(value.endDate) * 1000);
						//Y4 = date4.getFullYear() + '-';
						//M4 = date4.getMonth() + 1 + '-';
						//D4 = date4.getDate() + ' ';
						//date4 = Y4 + M4 + D4;
						//最终的时间
						//var res_data = date3 + " 至 " + date4;
						var res_data = value.beginDate + " 至 " + value.endDate;						
 
						trs = trs + res_data + "</td><td>";
						//判断拒绝理由是否为空
						if(!value.refuse){
							trs += "无";
						}
						else{
							trs += value.refuse;
						}
						
						//申请结果判断，2：未处理；1：通过；0：拒绝。
						if(value.status == 2){
							trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
						}
						else if(value.status == 1){
							trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
						}
						else{
							trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
						}

						trs = trs  +  "</tr>"

						tbody1 += trs;
						});
					}


					
					$("#tbody").append(tbody1);
					$(".pageDiv").createPage({
						pageNum: sessionStorage.allPage,
						current: 1,
						backfun: function(e) {
							//console.log(e);//回调
						}
					});

				},
				error: function(data) {
					alert("接收失败,code:" + data.status);
				}
			});   		
			function changePage(e){
				console.log(nowPage);
				console.log(e.getAttribute("value"));
				nowPage = e.getAttribute("value");
				$("#tbody").empty();
				var data3;
				var tbody1 = "";
						$.ajax({
							type: "GET",
							url: "https://carorder.sicau.edu.cn/userCar/showOrder",
							beforeSend: function (xhr) {
								xhr.setRequestHeader("userId", sessionStorage.userId);
							},
							dataType: "text", //后台返回格式问题
							data:{
								page:nowPage,
								pageSize:10,	
							},
							success: function(data) {
								//console.log(data3);
								//data3 = data3.slice(4);console.log(data3); 
								
								data3 = eval('(' + data + ')');
								if(data3.total%10 == 0){
									sessionStorage.allPage = parseInt(data3.total/10);
								}else{
									sessionStorage.allPage = parseInt(data3.total/10+1);
								}
								if (data3 == 0) {						
									tbody1 = "<tr><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td></tr>";
								}
								else{
									jQuery.each(data3.result, function(i, value) {
									var trs = "<tr><td hidden>" + value.id + "</td> <td>" + value.name + "</td> <td>" + value.plateId + "</td> <td>";
									if (value.campus==0) {
										trs = trs + "温江" + "</td> <td>";
									}
									else if (value.campus==1) {
										trs = trs + "雅安" + "</td> <td>";
									}
									else{
										trs = trs + "都江堰" + "</td> <td>";
									}

									//var date3 = new Date(parseInt(value.beginDate) * 1000);
									//Y3 = date3.getFullYear() + '-';
									//M3 = date3.getMonth() + 1 + '-';
									//D3 = date3.getDate() + ' ';
									//date3 = Y3 + M3 + D3;

									//var date4 = new Date(parseInt(value.endDate) * 1000);
									//Y4 = date4.getFullYear() + '-';
									//M4 = date4.getMonth() + 1 + '-';
									//D4 = date4.getDate() + ' ';
									//date4 = Y4 + M4 + D4;
									//最终的时间
									//var res_data = date3 + " 至 " + date4;
									var res_data = value.beginDate + " 至 " + value.endDate;						
			
									trs = trs + res_data + "</td><td>";
									//判断拒绝理由是否为空
									if(!value.refuse){
										trs += "无";
									}
									else{
										trs += value.refuse;
									}
									
									//申请结果判断，2：未处理；1：通过；0：拒绝。
									if(value.status == 2){
										trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
									}
									else if(value.status == 1){
										trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
									}
									else{
										trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
									}

									trs = trs  +  "</tr>"

									tbody1 += trs;
									});
								}
								$("#tbody").append(tbody1);
							},
							error: function(data) {
								alert("接收失败,code:" + data.status);
							}
										
							
			})
			}	
function jumpPage(){
	var searchId = $("#pageNum")
	console.log(searchId[0].value);
	nowPage = searchId[0].value
    // console.log(e.getAttribute("value"));

    var data3;
	var tbody1 = "";
	$("#tbody").empty();
			$.ajax({
				type: "GET",
				url: "https://carorder.sicau.edu.cn/userCar/showOrder",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("userId", sessionStorage.userId);
				},
				dataType: "text", //后台返回格式问题
				data:{
					page:searchId[0].value,
					pageSize:10,	
				},
				success: function(data) {
					//console.log(data3);
								//data3 = data3.slice(4);console.log(data3); 
						
								data3 = eval('(' + data + ')');
								if(data3.total%10 == 0){
									sessionStorage.allPage = parseInt(data3.total/10);
								}else{
									sessionStorage.allPage = parseInt(data3.total/10+1);
								}
								if (data3 == 0) {						
									tbody1 = "<tr><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td></tr>";
								}
								else{
									jQuery.each(data3.result, function(i, value) {
									var trs = "<tr><td hidden>" + value.id + "</td> <td>" + value.name + "</td> <td>" + value.plateId + "</td> <td>";
									if (value.campus==0) {
										trs = trs + "温江" + "</td> <td>";
									}
									else if (value.campus==1) {
										trs = trs + "雅安" + "</td> <td>";
									}
									else{
										trs = trs + "都江堰" + "</td> <td>";
									}

									//var date3 = new Date(parseInt(value.beginDate) * 1000);
									//Y3 = date3.getFullYear() + '-';
									//M3 = date3.getMonth() + 1 + '-';
									//D3 = date3.getDate() + ' ';
									//date3 = Y3 + M3 + D3;

									//var date4 = new Date(parseInt(value.endDate) * 1000);
									//Y4 = date4.getFullYear() + '-';
									//M4 = date4.getMonth() + 1 + '-';
									//D4 = date4.getDate() + ' ';
									//date4 = Y4 + M4 + D4;
									//最终的时间
									//var res_data = date3 + " 至 " + date4;
									var res_data = value.beginDate + " 至 " + value.endDate;						
			
									trs = trs + res_data + "</td><td>";
									//判断拒绝理由是否为空
									if(!value.refuse){
										trs += "无";
									}
									else{
										trs += value.refuse;
									}
									
									//申请结果判断，2：未处理；1：通过；0：拒绝。
									if(value.status == 2){
										trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
									}
									else if(value.status == 1){
										trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
									}
									else{
										trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
									}

									trs = trs  +  "</tr>"

									tbody1 += trs;
									});
								}
								$("#tbody").append(tbody1);
				},
				error: function(data) {
					alert("接收失败,code:" + data.status);
				}
	});
}
		$('#pageNumber').bind('keyup', function(event) {
	　　	if (event.keyCode == "13") {
	　　　　	//回车执行
	　　　　	change2();
	　　	}
		});
	</script>
	<script type="text/javascript" src="../js/judge.js"></script>
</html>